#include "general.h"

#include <buola/dbus/cproxy.h>

CBTermApp::CBTermApp()
    :   dbus::CObject<CBTermApp>("/org/buola/BTerm")
{
}

CBTermApp::~CBTermApp()
{
}

bool CBTermApp::Activate()
{
    if(dbus::get_session_bus()->RegisterService("org.buola.BTerm")) return true;

    //if we can't register... recycle existing browser
    dbus::CProxy lProxy(dbus::get_session_bus(),"org.buola.BTerm","/org/buola/BTerm");
    lProxy.CallIgnore("org.buola.BTerm","NewWindow");
    
    return false;
}

bool CBTermApp::Start()
{
    if(!Activate()) return false;
    CApp::Start();

    NewWindow();

    return true;
}

void CBTermApp::NewWindow()
{
    PMainWindow lWindow=new CMainWindow;
    lWindow->Resize(CSize_d(660,437));
    set_main_window(lWindow);
    lWindow->Map();
    mWindows.push_back(lWindow);
}
